# $Id$
# Maintainer : Tom Gundersen <teg@jklm.no>
# Maintainer : Ionut Biru <ibiru@archlinux.org>
# Contributor: Gabriel Martinez < reitaka at gmail dot com >

pkgname=libplist
pkgver=2.0.0
pkgrel=1
pkgdesc="A library to handle Apple Property List format whereas it's binary or XML"
url="http://libimobiledevice.org/"
arch=('i686' 'x86_64')
license=('GPL2' 'LGPL2.1')
depends=('glib2')
makedepends=('python2' 'cython2' 'python' 'cython' 'autoconf-archive')
options=('!makeflags')
source=(http://www.libimobiledevice.org/downloads/$pkgname-$pkgver.tar.bz2)
sha256sums=('3a7e9694c2d9a85174ba1fa92417cfabaea7f6d19631e544948dc7e17e82f602')

prepare() {
  cd $pkgname-$pkgver
  sed -e 's/AC_PYTHON_DEVEL/AX_PYTHON_DEVEL/' -i m4/cython_python.m4
  autoreconf -fi
}

build() {
  mkdir build-py2
  pushd build-py2
  PYTHON=/usr/bin/python2 CYTHON=/usr/bin/cython2 ../$pkgname-$pkgver/configure --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
  popd

  mkdir build-py3
  pushd build-py3
  PYTHON=/usr/bin/python CYTHON=/usr/bin/cython ../$pkgname-$pkgver/configure --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
  popd
}

package() {
  pushd build-py2
  make DESTDIR="$pkgdir" install
  popd
  pushd build-py3/cython
  make DESTDIR="$pkgdir" install
  popd
  install -D -m644 $pkgname-$pkgver/cython/plist.pxd "${pkgdir}"/usr/include/plist/cython/plist.pxd
}
